<?php

namespace App\Observers;


/**
 * Class ModelObserver
 * @package App\Observers
 */
class ModelObserver
{

    /**
     * hook数据更新
     *
     * @param $model
     */
    public function creating($model)
    {
//        if (in_array($model->table, ['file', 'contact'])) return ;
//        var_dump('-----in----creating', $model->table);
    }

    /**
     * hook数据更新
     *
     * @param $model
     */
    public function saving($model)
    {
        if (in_array($model->table, noTeamIdTableList())) return ;
        $teamId = session('teamId');
        if (!$teamId) return ;
//        echo "\r\n\$teamId:", $teamId, "\$model->team_id:", $model->team_id, "\r\n";
        $model->team_id = $teamId;
    }
}
